<!DOCTYPE html>
<html>


<head>

    <!--引入公用模板-->
    <%- include ../taglib/layout-map.ejs %>

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content" style="padding:5px">
    <div class="row animated fadeInDown">
        <div class="col-sm-3" id="mapleft" style="">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>设备数据</h5>
                    <div class="actions pull-right " onclick="displayMap()">
                        <i id="goHidden" class="fa fa-chevron-left" style="position: absolute;top: 23px;right:30px"></i>
                    </div>
                    <div class="ibox-tools">
                    <!--<a  onclick="displayMap()">-->
                        <!--<i class="fa fa-chevron-left"></i>-->
                    <!--</a>-->
                    </div>
                </div>
                <div class="ibox-content" style="height:400px">
                    <div class="row">
                        <form role="form" class="form-inline ">

                            <div class="form-group col-sm-4">
                                <label class="control-label" id="allcar">全部</label>
                            </div>
                            <div class="form-group col-sm-4">
                                <label class="control-label onlineDrivingArea1"  id="onlinecar">在线</label>
                            </div>
                            <div class="form-group col-sm-4 offlineIconArea">
                                <label class="control-label" id="offlinecar">离线</label>
                            </div>
                        </form>
                    </div>
                    <div class="row">
                        <form role="form" class="form-inline ">

                            <div class="input-group div-serch-input">
                                <input type="text" placeholder="" class="input form-control"
                                       id="serchStr" style="width: 100px">
                                <span class="input-group-btn">
                                                <button type="button" class="btn btn btn-primary" onclick="query(2)"><i
                                                            class="fa fa-search"></i> 搜索
                                                </button>
                                            </span>
                            </div>
                            <div class="btn-group   div-serch-input">
                                <button type="button" class="btn btn-primary"><i class="fa fa-bars"></i></button>
                                <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown"
                                        aria-haspopup="true" aria-expanded="false">
                                    <span class="caret"></span>
                                    <!--<span class="sr-only">Toggle Dropdown</span>-->
                                </button>
                                <ul class="dropdown-menu">
                                    <li><label onclick="clickMenuItem('0','lableoffline')"><input type="checkbox"
                                                                                                  checked="checked"
                                                                                                  id="lableoffline"
                                                                                                  onchange="changeMenuItem('0',this)">
                                            显示离线</label></li>
                                    <li><label onclick="clickMenuItem('1','lableonline')"><input type="checkbox"
                                                                                                 checked="checked"
                                                                                                 id="lableonline"
                                                                                                 onchange="changeMenuItem('0',this)">
                                            显示行驶</label></li>
                                    <li><label onclick="clickMenuItem('2','lablestop')"><input type="checkbox"
                                                                                               checked="checked"
                                                                                               id="lablestop"
                                                                                               onchange="changeMenuItem('0',this)">
                                            显示停止</label></li>
                                    <li><label onclick="clickMenuItem('3','lablebj')"><input type="checkbox"
                                                                                             checked="checked"
                                                                                             id="lablebj"
                                                                                             onchange="changeMenuItem('0',this)">
                                            显示报警</label></li>
                                    <li><label><input type="checkbox" checked="checked"
                                                      onchange="changeMenuItem('0',this)"> 显示未定位</label></li>
                                    <li><label onclick="clickMenuItem('5','lablecs')">
                                            <input type="checkbox"
                                                                                             checked="checked"
                                                                                             id="lablecs"
                                                                                             onchange="changeMenuItem('0',this)">
                                            显示超速</label></li>
                                </ul>
                            </div>
                        </form>
                    </div>
                    <div class="row  pre-scrollable" style="height: 300px">
                        <div id='external-events'>
                            <ul id="kindTree" class="ztree">
                            </ul>
                        </div>
                    </div>
                </div>
            </div>

            <div class="ibox float-e-margins" >
                <!--<div class="ibox-title">-->
                    <!--<h5>图例</h5>-->
                <!--</div>-->
                <div class="ibox-content">
                    <div class="row">
                    <div class="col-md-12 stateArea" id="IdentificationInfo" style="padding:0;">
                        <div class="col-md-12 form-group">
                            <div class="col-md-4 col-sm-4 col-xs-4 stateIcon text-center tulipadding">
														<span class="offlineIconArea" style="cursor:pointer"
                                                              id="chooseMiss" type="button">
															<span class="btnImage iconArea offlineIcon_ico_docu"></span>离线
														</span>
                            </div>
                            <div class="col-md-4 col-sm-4 col-xs-4 btnPadding text-center tulipadding">
														<span class="onlineNotPositioningArea" style="cursor:pointer"
                                                              id="chooseNot" type="button">
															<span class="btnImage iconArea onlineNotPositioning_ico_docu"></span>未定位
														</span>
                            </div>
                            <div class="col-md-4 col-sm-4 col-xs-4 stateIcon text-center tulipadding">
														<span type="button" id="chooseAlam" style="cursor:pointer"
                                                              class="warningArea">
															<span class="btnImage iconArea warning_ico_docu"></span>报警
														</span>
                            </div>
                        </div>
                        <div class="col-md-12 form-group">
                            <div class="col-md-4 col-sm-4 col-xs-4 btnPadding text-center tulipadding">
														<span class="onlineDrivingArea" style="cursor:pointer"
                                                              id="chooseRun" type="button">
															<span class="btnImage iconArea onlineDriving_ico_docu"></span>行驶
														</span>
                            </div>
                            <div class="col-md-4 col-sm-4 col-xs-4 btnPadding text-center tulipadding">
														<span type="button" id="chooseStop" style="cursor:pointer"
                                                              class="onlineParkingArea">
															<span class="btnImage iconArea onlineParking_ico_docu"></span>停止
														</span>
                            </div>
                            <div class="col-md-4 col-sm-4 col-xs-4 btnPadding text-center tulipadding">
														<span type="button" id="chooseOverSeep" style="cursor:pointer"
                                                              class="speedLimitWarningArea">
															<span class="btnImage iconArea speedLimitWarning_ico_docu"></span>超速
														</span>
                            </div>
                        </div>
                        <legend></legend>
                        <!--0绿色是跑的，1红色是异常的，2灰色是离线的,3蓝色是停止的，-->
                        <div class="col-md-12 form-group">
                            <div class="col-md-3 col-sm-3 col-xs-3 btnPadding text-center tulipadding">
														<span class="onlineDrivingArea" style="cursor:pointer"
                                                              id="chooseRun" type="button">
															<span class="btnOnline iconArea1"></span>行驶
														</span>
                            </div>
                            <div class="col-md-3 col-sm-3 col-xs-3 btnPadding text-center tulipadding">
														<span type="button" id="chooseStop" style="cursor:pointer"
                                                              class="onstopArea">
															<span class="btnStop iconArea1"></span>停止
														</span>
                            </div>
                            <div class="col-md-3 col-sm-3 col-xs-3 btnPadding text-center tulipadding">
														<span type="button" id="chooseOverSeep" style="cursor:pointer"
                                                              class="offlineIconArea">
															<span class="btnOffline iconArea1"></span>离线
														</span>
                            </div>
                            <div class="col-md-3 col-sm-3 col-xs-3 btnPadding text-center tulipadding">
														<span type="button" id="chooseOverSeep" style="cursor:pointer"
                                                              class="onlineParkingArea">
															<span class="btnError iconArea1"></span>异常
														</span>
                            </div>
                        </div>
                    </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-9 clearfix" id="mapright" style="padding-left:5px">
            <div class="row animated fadeInDown">
                <div class="col-sm-12 clearfix" style="padding-left:5px;margin-top: 2px;margin-bottom: 0px">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5 style="padding-left: 30px">地图监控</h5>
                            <div class="ibox-tools" id="righttool">
                                <a  onclick="exitqj()">
                                    <i class="fa fa-map"></i>
                                </a>
                            </div>
                        </div>
                        <div class="ibox-content" style="height: 400px;padding:1px">
                            <div style="height: 100%;-webkit-transition: all 0.5s ease-in-out;transition: all 0.5s ease-in-out;">
                                <div id="map"
                                     style="height: 100%;-webkit-transition: all 0.5s ease-in-out;transition: all 0.5s ease-in-out;"></div>
                                <div id="app-right-top">
                                    <div id="user-center" class="ui3-user-center-wrap">
                                        <div class="avatar-abstract"></div>
                                    </div>
                                </div>
                            </div>
                            <div id="goShow"  style="display: none;" onclick="displayLeft()">
                                <i id="goHidden" class="fa fa-chevron-right"></i>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-12 clearfix " style="padding-left:1px;margin-top: 0px;margin-bottom: 0px">
                        <div class="ibox float-e-margins" >
                            <!--collapsed-->
                            <!--<div class="ibox-title">-->
                                <!--<div>-->
                                    <!--<h5 id="warningRef">-->

                                    <!--</h5>-->
                                <!--</div>-->

                                <!--<div class="ibox-tools">-->
                                    <!--<a class="collapse-link">-->
                                        <!--<i class="fa fa-chevron-up"></i>-->
                                    <!--</a>-->
                                <!--</div>-->
                            <!--</div>-->
                            <div class="ibox-content">
                                <!--<div class="ibox-tools">-->
                                    <!--<a class="collapse-link">-->
                                        <!--<i class="fa fa-chevron-up"></i>-->
                                    <!--</a>-->
                                <!--</div>-->
                                <div class="tabs-container">
                                    <ul class="nav nav-tabs">
                                        <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true">车辆实时信息</a>
                                        </li>
                                        <li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false">报警信息</a>
                                        </li>
                                        <li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false" id="warningRef"></a>
                                        </li>
                                    </ul>
                                    <div class="tab-content">
                                        <div id="tab-1" class="tab-pane active">
                                            <div class="panel-body">
                                                <div>
                                                    <div>
                                                        <table id="gpsTable"
                                                               class="table table-striped table-bordered table-hover dataTables-example">
                                                            <thead>
                                                            <tr>
                                                                <!--<th>-->
                                                                <!--</th>-->
                                                                <th >id</th>
                                                                <th >操作</th>
                                                                <th width="100px">车牌号</th>
                                                                <th width="100px">定位时间</th>
                                                                <th width="100px">通信时间</th>
                                                                <th width="100px">客户</th>
                                                                <th width="80px">定位</th>
                                                                <th width="200px">状态</th>
                                                                <!--<th>ACC</th>-->
                                                                <!--<th>时长(分钟)</th>-->
                                                                <!--<th>主电状态</th>-->
                                                                <!--<th>在线状态</th>-->
                                                                <th width="150px">设备地址</th>
                                                                <th width="150px">SIM卡</th>
                                                                <th width="80px">速度</th>
                                                                <th width="80px">方向</th>
                                                                <th width="100px">日里程</th>
                                                                <th width="100px">月里程</th>



                                                                <!--<th width="200px">当日油耗</th>-->
                                                                <!--<th width="200px">总油耗</th>-->
                                                                <!--<th>位置</th>-->

                                                            </tr>
                                                            </thead>
                                                            <tbody>
                                                            </tbody>
                                                        </table>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div id="tab-2" class="tab-pane">
                                            <div class="panel-body">
                                                <table id="warningTable"
                                                       class="table table-striped table-bordered table-hover dataTables-example" style="    width: 900px;">
                                                    <thead>
                                                    <tr>
                                                        <th>
                                                        </th>
                                                        <th width="200px">id</th>
                                                        <th width="200px">车牌号</th>
                                                        <th width="200px">客户</th>
                                                        <th width="200px">对象类型</th>
                                                        <!--<th width="200px">类型</th>-->
                                                        <th width="200px">人员</th>
                                                        <th width="200px">时间</th>
                                                        <th width="200px">位置</th>
                                                        <th width="200px">状态</th>
                                                        <th width="200px">操作</th>
                                                    </tr>
                                                    </thead>
                                                    <tbody>
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="modal inmodal" id="myModal" role="dialog" data-width="500px"
                                         data-height="400px" aria-hidden="true">
                                        <div class="modal-dialog">
                                            <div class="modal-content animated bounceInRight">
                                                <div class="modal-header">
                                                    <h4 class="modal-title">车辆基本信息</h4>
                                                </div>
                                                <div class="modal-body" style="max-height: 400px; ">

                                                    <form class="form-horizontal m-t" id="editForm" method="get">
                                                        <input id="id" name="id" type="hidden">
                                                        <input id="baseTerminalId" name="baseTerminalId" type="hidden">
                                                        <input id="baseCarTypeId" name="baseCarTypeId" type="hidden">
                                                        <input id="deptId" name="deptId" type="hidden">

                                                        <div class="form-group">
                                                            <label class="col-sm-3 control-label">车牌号</label>

                                                            <div class="col-sm-8">
                                                                <input id="baseCarNo" name="baseCarNo" class="form-control"
                                                                       placeholder="车牌号必填" type="text" aria-required="true"
                                                                       aria-invalid="true" readonly="readonly">
                                                            </div>
                                                        </div>

                                                        <div class="form-group">
                                                            <label class="col-sm-3 control-label">车辆品牌</label>

                                                            <div class="col-sm-8">
                                                                <input id="baseCarBrand" name="baseCarBrand"
                                                                       class="form-control"
                                                                       placeholder="车辆品牌必填" type="text" aria-required="true"
                                                                       aria-invalid="true" readonly="readonly">
                                                                <!--可以增加提示-->
                                                                <!--<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 这里写点提示的内容</span>-->
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="col-sm-3 control-label">车辆类型</label>

                                                            <div class="col-sm-8">
                                                                <input id="baseCarTypeName" name="baseCarTypeName"
                                                                class="form-control"
                                                                placeholder="车辆类型必填" type="text"
                                                                aria-required="true" aria-invalid="true" readonly="readonly">

                                                                <!--<select class="form-control m-b" id="baseCarTypeId"-->
                                                                        <!--name="baseCarTypeId" type="select">-->

                                                                <!--</select>-->

                                                                <!--可以增加提示-->
                                                                <!--<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 这里写点提示的内容</span>-->
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="col-sm-3 control-label">排量</label>

                                                            <div class="col-sm-8">

                                                                <input type="text" id="baseCarOutput" name="baseCarOutput"
                                                                       class="form-control" value="1" aria-required="true"
                                                                       aria-invalid="true" readonly="readonly"
                                                                >

                                                                <!--<div class="input-group-btn-vertical ">-->
                                                                    <!--<button class="btn btn-default" id="first-of-type"-->
                                                                            <!--type="button"><i-->
                                                                                <!--class="fa fa-caret-up"></i></button>-->
                                                                    <!--<button class="btn btn-default" id="last-of-type"-->
                                                                            <!--type="button"><i-->
                                                                                <!--class="fa fa-caret-down"></i></button>-->
                                                                <!--</div>-->

                                                            </div>


                                                        </div>

                                                        <div class="form-group">
                                                            <label class="col-sm-3 control-label">设备地址</label>

                                                            <div class="col-sm-8">
                                                                <input id="baseTerminaName" name="baseTerminaName"
                                                                class="form-control" placeholder="设备地址必填" type="text"
                                                                aria-required="true" aria-invalid="true" readonly="readonly">

                                                                <!--<select class="form-control m-b" id="baseTerminalId"-->
                                                                        <!--name="baseTerminalId" type="select">-->

                                                                <!--</select>-->
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="col-sm-3 control-label">SIM</label>

                                                            <div class="col-sm-8">
                                                                <input id="baseTerminalSim" name="baseTerminalSim"
                                                                class="form-control" placeholder="设备地址必填" type="text"
                                                                aria-required="true" aria-invalid="true" readonly="readonly">

                                                                <!--<select class="form-control m-b" id="baseTerminalId"-->
                                                                        <!--name="baseTerminalId" type="select">-->

                                                                <!--</select>-->
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="col-sm-3 control-label">车主姓名</label>

                                                            <div class="col-sm-8">
                                                                <input id="userName" name="userName" class="form-control"
                                                                       placeholder="车主姓名必填" type="text" aria-required="true"
                                                                       aria-invalid="true" readonly="readonly">
                                                                <!--可以增加提示-->
                                                                <!--<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 这里写点提示的内容</span>-->
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="col-sm-3 control-label">车主电话</label>

                                                            <div class="col-sm-8">
                                                                <input id="userPhone" name="userPhone" class="form-control"
                                                                       placeholder="车主电话必填" type="text" aria-required="true"
                                                                       aria-invalid="true" readonly="readonly">
                                                                <!--可以增加提示-->
                                                                <!--<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 这里写点提示的内容</span>-->
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="col-sm-3 control-label">车辆别名</label>

                                                            <div class="col-sm-8">
                                                                <input id="baseCarName" name="baseCarName"
                                                                       class="form-control"
                                                                       placeholder="车辆别名必填" type="text" aria-required="true"
                                                                       aria-invalid="true" readonly="readonly">
                                                                <!--可以增加提示-->
                                                                <!--<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 这里写点提示的内容</span>-->
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="col-sm-3 control-label">发动机号</label>

                                                            <div class="col-sm-8">
                                                                <input id="baseCarFdNo" name="baseCarFdNo"
                                                                       class="form-control"
                                                                       placeholder="发动机号必填" type="text" aria-required="true"
                                                                       aria-invalid="true" readonly="readonly">
                                                                <!--可以增加提示-->
                                                                <!--<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 这里写点提示的内容</span>-->
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="col-sm-3 control-label">机架号</label>

                                                            <div class="col-sm-8">
                                                                <input id="baseCarJjNo" name="baseCarJjNo"
                                                                       class="form-control"
                                                                       placeholder="机架号必填" type="text" aria-required="true"
                                                                       aria-invalid="true" readonly="readonly">
                                                                <!--可以增加提示-->
                                                                <!--<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 这里写点提示的内容</span>-->
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="col-sm-3 control-label">燃料类型</label>

                                                            <div class="col-sm-8">
                                                                <input id="baseCarRlType" name="baseCarRlType"
                                                                class="form-control"
                                                                placeholder="燃料类型必填" type="text"
                                                                aria-required="true" aria-invalid="true"  readonly="readonly">
                                                                <!--<select class="form-control m-b" id="baseCarRlType"-->
                                                                        <!--name="baseCarRlType" type="text">-->
                                                                    <!--<option value="汽油">汽油</option>-->
                                                                    <!--<option value="柴油">柴油</option>-->
                                                                    <!--<option value="新能源">新能源</option>-->
                                                                <!--</select>-->
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="col-sm-3 control-label">所属省份</label>

                                                            <div class="col-sm-8">
                                                                <input id="baseCarOfProvince" name="baseCarOfProvince"
                                                                       class="form-control" placeholder="所属省份必填" type="text"
                                                                       aria-required="true" aria-invalid="true" readonly="readonly">
                                                                <!--可以增加提示-->
                                                                <!--<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 这里写点提示的内容</span>-->
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="col-sm-3 control-label">所属市区</label>

                                                            <div class="col-sm-8">
                                                                <input id="baseCarOfCity" name="baseCarOfCity"
                                                                       class="form-control"
                                                                       placeholder="所属市区必填" type="text" aria-required="true"
                                                                       aria-invalid="true" readonly="readonly">
                                                                <!--可以增加提示-->
                                                                <!--<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 这里写点提示的内容</span>-->
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="col-sm-3 control-label">初始里程</label>

                                                            <div class="col-sm-8">
                                                                <input id="baseCarDis" name="baseCarDis"
                                                                       class="form-control"
                                                                       placeholder="初始里程必填" type="text" aria-required="true"
                                                                       aria-invalid="true"
                                                                       number="true" maxlength="10" readonly="readonly">

                                                                <!--可以增加提示-->
                                                                <!--<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 这里写点提示的内容</span>-->
                                                            </div>
                                                        </div>

                                                    </form>
                                                </div>
                                                <div class="modal-footer">

                                                    <button type="button" class="btn btn-white" onclick="closeModal()">关闭
                                                    </button>
                                                    <!--<button type="button" class="btn btn-primary" onclick="save()">保存-->
                                                    <!--</button>-->
                                                </div>
                                            </div>
                                        </div>
                                    </div>


                                </div>
                            </div>
                        </div>
                    </div>

                </div>

            </div>
        </div>
    </div>
</div>
<!--<input type='button' text='dianji' onclick="play_sound()"/>-->
<input type="hidden" id="h_c_car_id">
<input type="hidden" id="h_c_car_baseCarNo">
<input type="hidden" id="h_all_car_id">
<%- include ../taglib/layout-content.ejs %>
<script type="text/javascript">
    var gpsTable;
    var warningTable;
    var soundurl="http://localhost:3000/css/sound/warning.mp3"
    $(document).ready(function () {
        gpsTable = $('#gpsTable').dataTable({
            "lengthChange": true,//是否允许用户自定义显示数量
//            "searching": false,//本地搜索
//            "scrollY": "220px",//dt高度
            scrollX: true,
            "autoWidth": true,//自动宽度
            "paging": false, // 禁止分页
            "dom": '<"top"<"clear">>rt<"bottom"ilp<"clear">>',
//            "lengthChange": false,//是否允许用户自定义显示数量
            "ajax": {
                "url": "/map/terminals?allCarIds=0,",
                "dataSrc": "rows"
            },
            serverSide: true,
            columns: [
//                {
//                    "sClass": "text-center",
//                    "data": "id",
//                    'checkboxes': {
//                        'selectRow': true,
//                    },
//
//                },
                {"sClass": "text-center", data: 'id'},
                {
                    "bSortable": false,//禁止排序
                    "orderable": false,
                    "sClass": "text-center",
                    data: function (d, e, f, g) {//这里给最后一列返回一个操作列表
                        //e是得到的json数组中的一个item ，可以用于控制标签的属性。
                        var id = d.id
                        var index = g.row
                        return '' +
                            '<button class="btn btn-info btn-sm btn-select-row" type="button" ' +
                            'onclick="editGps(' +index+','+ id + ')" data-toggle="modal"   >' +
                            '<i class="fa fa-edit"></i> <span class="bold">查看车辆</span>';
                    }
                },
                //禁止排序
                {"sClass": "text-center", data: 'baseCarNo', "bSortable": false, "orderable": false},

                {"sClass": "text-center", data: 'gpsDate', "bSortable": false, "orderable": false},
                {
                    "sClass": "text-center", data: "onlinetime", "bSortable": false, "orderable": false
                },
                {"sClass": "text-center", data: 'deptName', "bSortable": false, "orderable": false},
//                {"sClass": "text-center", data: 'elType', "bSortable": false, "orderable": false},
//                {"sClass": "text-center", data: 'baseCarNoColour'},
//                定位
                {
                    "sClass": "text-center", data: function (e) {//这里给最后一列返回一个操作列表
                    //e是得到的json数组中的一个item ，可以用于控制标签的属性。
                    var gpsDate = e.gpsDate;
                    var onlinetime = e.onlinetime;
                    var result = "是";
                    if(gpsDate && onlinetime){
                        debugger;
                        var totalMilliseconds = Math.abs(Date.parse(new Date(gpsDate)) - Date.parse(new Date(onlinetime)));
                        var totalMinutes=parseInt(totalMilliseconds / 1000 / 60);
                        if(totalMinutes>2){
                            result="否"
                        }
                    }else{
                        result="否"
                    }
                    return result
                }, "bSortable": false, "orderable": false
                },
//                状态：主电正常，熄火，时长
                {
                    "sClass": "text-center", data: function (e) {//这里给最后一列返回一个操作列表
                    //e是得到的json数组中的一个item ，可以用于控制标签的属性。
                    var gpsPowerStatus = e.gpsPowerStatus;
                    var acc = e.accFlag;
                    var oneHigh = e.oneHigh;
                    var sc=Math.floor(oneHigh/60) + "小时" + Math.floor(oneHigh%60) + "分" ;
                    var str=""
                    if(gpsPowerStatus == 1){
                        str="主电正常, "
                    }else{
                        str="主电异常, "
                    }
                    if (acc == 1) {
                        str = str+"点火, "
                    }else{
                        str = str+"熄火, "
                    }
                    if(oneHigh){
                        str=str+" 时长: "+sc
                    }else{
                        str=str+" 时长: 0 分钟"
                    }



//                    var result = '<a class="btn btn-warning btn-rounded" >熄火</a>'
////                    车牌号颜色[1-4]黄白蓝黑
//                    if (d == 1) {
//                        result = '<a class="btn btn-default btn-rounded" >点火</a>'
//                    }
                    return str
                }, "bSortable": false, "orderable": false
                },
//                {
//                    "sClass": "text-center", data: "oneHigh", "bSortable": false, "orderable": false
//                },
//                {
//                    "sClass": "text-center", data: function (e) {//这里给最后一列返回一个操作列表
//                    //e是得到的json数组中的一个item ，可以用于控制标签的属性。
//                    var d = e.gpsPowerStatus;
////                    1=正常  0=异常
//                    var result = '<a class="btn btn-warning btn-rounded" >异常</a>'
////                    车牌号颜色[1-4]黄白蓝黑
//                    if (d == 1) {
//                        result = '<a class="btn btn-default btn-rounded" >正常</a>'
//                    }
//                    return result
//                }, "bSortable": false, "orderable": false
//                },
//                {
////                    online
//                    "sClass": "text-center", data: function (e) {//这里给最后一列返回一个操作列表
//                    //e是得到的json数组中的一个item ，可以用于控制标签的属性。
////                    debugger;
////                    accFlag
//                    var d = e.online;
//                    var result = '<a class="btn btn-info btn-rounded" >在线</a>'
////                    车牌号颜色[1-4]黄白蓝黑
//                    if (d == 1) {
//                        result = '<a class="btn btn-info btn-rounded" >在线</a>'
//                    } else if (d == 0) {
//                        result = '<a class="btn btn-danger btn-rounded" >离线</a>'
//                    }
//                    return result
//                }, "bSortable": false, "orderable": false
//                },
                {"sClass": "text-center", data: 'terminal', "bSortable": false, "orderable": false},
                {"sClass": "text-center", data: 'sim', "bSortable": false, "orderable": false},
                {"sClass": "text-center", data: 'speed', "bSortable": false, "orderable": false},
//                {"sClass": "text-center", data: 'driection', "bSortable": false, "orderable": false},
                {"sClass": "text-center", data: function (e) {//这里给最后一列返回一个操作列表
                    //e是得到的json数组中的一个item ，可以用于控制标签的属性。
                    var driection = e.driection;
                    if(driection){
                        return queryAngle(driection);
                    }else{
                        return "北"
                    }


                }, "bSortable": false, "orderable": false},
                {"sClass": "text-center", data: 'daydis', "bSortable": false, "orderable": false},
                {"sClass": "text-center", data: 'monthDis', "bSortable": false, "orderable": false}
//                {"sClass": "text-center", data: 'jd', "bSortable": false, "orderable": false},
//                {"sClass": "text-center", data: 'wd', "bSortable": false, "orderable": false},





//                {
//                    "sClass": "text-center", data: function (e) {//这里给最后一列返回一个操作列表
//                    //e是得到的json数组中的一个item ，可以用于控制标签的属性。
//                    var jd = e.jd;
//                    var wd = e.wd;
//                    var result = jd + wd;
//                    return result
//                }, "bSortable": false, "orderable": false
//                },

            ],
            //排序
//            'order': [[1, 'desc']],
            initComplete: function (setting, json) {
                //隐藏列
                visiblecolumn(gpsTable, 0, false);
//                visiblecolumn(gpsTable,13, false);
//                visiblecolumn(gpsTable,11, false);
//                visiblecolumn(gpsTable,12, false);
//                visiblecolumn(6,false)
            },
        });
        $('#gpsTable tbody').on('click', 'tr', function () {
            $('#gpsTable tbody').on('click', 'tr', function () {
                if ($(this).hasClass('selected')) {
                    $(this).removeClass('selected');
                    cleanAll();
                } else {
                    gpsTable.$('tr.selected').removeClass('selected');
                    $(this).addClass('selected');
                    var row = gpsTable.DataTable().rows('.selected').data()[0];
                    var carId = row.id;
                    $("#h_c_car_id").val(carId);
                    queryCarsByNo(carId,"0");
                }

            });

        });
        warningTable = $('#warningTable').dataTable({
            "lengthChange": true,//是否允许用户自定义显示数量
//            "searching": false,//本地搜索
//            "scrollY": "220px",//dt高度
            "autoWidth": true,//自动宽度
            "dom": '<"top"<"clear">>rt<"bottom"ilp<"clear">>',
//            "lengthChange": false,//是否允许用户自定义显示数量
            "ajax": {
                "url": "/map/warnings",
                "dataSrc": "rows"
            },
            bAutoWidth:false,//取消自动宽度
            serverSide: true,
            columns: [
                {
                    "sClass": "text-center",
                    "data": "id",
                    'checkboxes': {
                        'selectRow': true,
                    },

                },
                {"sClass": "text-center", data: 'id'},
                //禁止排序
                {"sClass": "text-center", data: 'baseCarNo', "bSortable": false, "orderable": false},
                {"sClass": "text-center", data: 'deptName', "bSortable": false, "orderable": false},
//                {"sClass": "text-center", data: 'elType', "bSortable": false, "orderable": false},
                {
//                    warningType
                    "sClass": "text-center", data: function (e) {//这里给最后一列返回一个操作列表
                    //e是得到的json数组中的一个item ，可以用于控制标签的属性。
//                    debugger;
                    var d = e.warningType;
//                    1-驶入  2-驶出 3-超速 4-路线偏离 5-停车超时报警  6-疲劳驾驶报警 7-凌晨行车报警
                    var result = "";
                    if (d == 1) {
                        result = '驶入报警'
                    } else if (d == 2) {
                        result = '驶出报警'
                    } else if (d == 3) {
                        result = '超速报警'
                    } else if (d == 4) {
                        result = '路线偏离报警'
                    } else if (d == 5) {
                        result = '停车超时报警'
                    } else if (d == 6) {
                        result = '疲劳驾驶报警'
                    } else if (d == 7) {
                        result = '凌晨行车报警'
                    }
                    return '<a class="btn btn-danger btn-rounded" >' + result + '</a>'
                }, "bSortable": false, "orderable": false
                },
                {"sClass": "text-center", data: 'user_name', "bSortable": false, "orderable": false},
                {"sClass": "text-center", data: 'waringtime', "bSortable": false, "orderable": false},
//                {"sClass": "text-center", data: 'jd', "bSortable": false, "orderable": false},
//                {"sClass": "text-center", data: 'wd', "bSortable": false, "orderable": false},
                {
                    "sClass": "text-center", data: function (e) {//这里给最后一列返回一个操作列表

                    var jd = e.jd;
                    var wd = e.wd;
                    var result = jd + wd;
                    return result
                }, "bSortable": false, "orderable": false
                },
                {
                    "sClass": "text-center", data: function (e) {//这里给最后一列返回一个操作列表
                    //e是得到的json数组中的一个item ，可以用于控制标签的属性。
//                    debugger;
//                    accFlag
                    var d = e.waringstate;
                    var result = '<a class="btn btn-info btn-rounded" >已处理</a>'
//                    车牌号颜色[1-4]黄白蓝黑
                    if (d == 1) {
                        result = '<a class="btn btn-info btn-rounded" >已处理</a>'
                    } else if (d == 0) {
                        result = '<a class="btn btn-warning btn-rounded" >未处理</a>'
                    }
                    return result
                }, "bSortable": false, "orderable": false
                },
                {
                    "bSortable": false,//禁止排序
                    "orderable": false,
                    "sClass": "text-center",
                    data: function (d, e, f, g) {//这里给最后一列返回一个操作列表
                        //e是得到的json数组中的一个item ，可以用于控制标签的属性。
                        var id = d.id
                        var index = g.row
                        return '' +
                            '<button class="btn btn-info btn-sm btn-select-row" type="button" onclick="edit(' + index + ')" data-toggle="modal"   ><i class="fa fa-edit"></i> <span class="bold">处理</span>'
                    }
                }
            ],
            //排序
//            'order': [[1, 'desc']],
            initComplete: function (setting, json) {
                //隐藏列
                visiblecolumn(warningTable, 0, false);
                visiblecolumn(warningTable, 1, false);
                visiblecolumn(warningTable,7, false);
//                visiblecolumn(12, false);
//                visiblecolumn(13, false);
//                visiblecolumn(6,false)
            },
        });
    });
    //    部门车辆树
    var urlTree;
    $(function () {
        urlTree = '/tree/deptCar';
        init_tree('id', 'parentId', 'name', fnClick, fnCheck, "checkbox");
        loadMyTree(urlTree);
        $('body').everyTime('2das', 'refData', refData, 0, true);
        $('body').everyTime('2hs', 'refData1', refData1, 0, true);
        querycartitle();

    });
    //    隐藏列
    function visiblecolumn(table, c, visible) {
        table.DataTable().column(c).visible(visible)
    }

    var num = 0;
    function clickMenuItem(serchvalue, name) {

        num = num + 1;
        event.stopPropagation();
        if (num == 2) {
            var cobchecked = $("#" + name).prop('checked');
            num = 0
            var offChecked = $("#lableoffline").prop('checked');
            var nlineChecked = $("#lableonline").prop('checked');
            var stopChecked = $("#lablestop").prop('checked');
            var bjChecked = $("#lablebj").prop('checked');
            var csChecked = $("#lablecs").prop('checked');

            if (!offChecked && !nlineChecked && !stopChecked && !bjChecked && !csChecked) {
                highlight_Expand_ztree_content('kindTree');
            } else {

                highlightAndExpand_ztree_content('kindTree');

                var tempNodes = [];
                if (offChecked) {
                    var nodesoff = search_ztree_content('kindTree', 'warningType', "0");
                    hightreeBynodes('kindTree', nodesoff);
                }
                if (nlineChecked) {
                    var nodesnline = search_ztree_content('kindTree', 'warningType', "1");
                    hightreeBynodes('kindTree', nodesnline);

                }
                if (stopChecked) {
                    var nodesstop = search_ztree_content('kindTree', 'warningType', "2");
                    hightreeBynodes('kindTree', nodesstop);

                }
                if (bjChecked) {
                    var nodesbj = search_ztree_content('kindTree', 'warningType', "3");
                    hightreeBynodes('kindTree', nodesbj);

                }
                if (csChecked) {
                    var nodescs = search_ztree_content('kindTree', 'warningType', "5");
                    hightreeBynodes('kindTree', nodescs);
                }

            }
        }


    }

    function changeMenuItem() {
        num = 0;
    }
    /**
     * 树刷新数据
     */
    function query() {
        var str=$("#serchStr").val();
        if(str){
            search_ztree('kindTree', 'serchStr');
        }else{
            loadMyTree(urlTree);
        }


    }

    function displayMap() {
        $("#mapleft").css('display','none');
        $("#goShow").css('display','block');
        $("#mapright").removeClass("col-sm-9").addClass("col-sm-12").css("padding-left","30px");


    }
    function displayLeft() {
        $("#mapleft").css('display','block');
        $("#goShow").css('display','none');
        $("#mapright").removeClass("col-sm-12").addClass("col-sm-9").css("padding-left","5px");;


    }
    function exitqj() {
        map.removeTileLayer(traffic);
        debugger;
        panorama.hide();
    }

</script>
<script type="text/javascript">
    function play_sound() {
        var div = document.getElementById('div1');
        div.innerHTML = '<embed id="player" height="0" width="0"  src="../css/sound/warning.mp3"></embed>';

    }
    function edit(index) {
        var data = warningTable.DataTable().rows(index).data()
        debugger;
        if (data && data[0]) {
           var type=1;
           var id=data[0].id;
           debugger;
            $.ajax({
                type: "GET",
                url: "/map/warningCl",
                cache: false,
                async: false,
                data: {
                    id:id,
                    type:type
                },
                dataType: "json",
                success: function (data) {
//                            swal("删除成功！", "您已经永久删除了这条信息。", "success");
                    swal("系统提示", data, "success");
                    querywarnings();
                }
            })
        } else {
            swal("已取消", "数据错误！", "warning");
        }
    }
</script>
<!--map-->
<script type="text/javascript">
    // 百度地图API功能
    var map;
    var panorama;
    var carIocnPath = "/js/mapPlugins/img/";
    var lastMark = [];
    var lastCarMark = {};//终端数组
    var opts = {
        width: 350,     // 信息窗口宽度
        height: 0,     // 信息窗口高度
//        width : 0,
//        height: 0,
//        title : "实时信息" , // 信息窗口标题
        panel: "panel",
        enableMessage: true,//设置允许信息窗发送短息
        searchTypes: [
            BMAPLIB_TAB_SEARCH,   //周边检索
            BMAPLIB_TAB_TO_HERE,  //到这里去
            BMAPLIB_TAB_FROM_HERE //从这里出发
        ]
    };
    //    var carIcon="car_online0.fw";
    $(function () {
        map = new BMap.Map('map');
        map.addControl(new BMap.NavigationControl());
        map.addControl(new BMap.ScaleControl());
        map.addControl(new BMap.OverviewMapControl());
        map.enableScrollWheelZoom();
        map.addControl(new BMap.MapTypeControl());


        var contextMenu = new BMap.ContextMenu();
        var txtMenuItem = [
            {
                text: '放大',
                callback: function () {
                    map.zoomIn()
                }
            },
            {
                text: '缩小',
                callback: function () {
                    map.zoomOut()
                }
            },
            {
                text: '放置到最大级',
                callback: function () {
                    map.setZoom(18)
                }
            },
            {
                text: '查看全国',
                callback: function () {
                    map.setZoom(4)
                }
            },
            {
                text: '关闭实景地图',
                callback: function () {
                    exitqj();
                }
            },
            {
                text: '在此添加标注',
                callback: function (p) {
                    var marker = new BMap.Marker(p), px = map.pointToPixel(p);
                    map.addOverlay(marker);
                }
            }
        ];
        for (var i = 0; i < txtMenuItem.length; i++) {
            contextMenu.addItem(new BMap.MenuItem(txtMenuItem[i].text, txtMenuItem[i].callback, 100));
            if (i == 1 || i == 3) {
                contextMenu.addSeparator();
            }
        }
        map.addContextMenu(contextMenu);
        var jw = '<%= jw %>';
        initPoint(jw);


//
        panorama = new BMap.Panorama('map');
        panorama.setPov({heading: -40, pitch: 6});
        var stCtrl = new BMap.PanoramaControl(); //构造全景控件
        stCtrl.setOffset(new BMap.Size(50, 50));
        map.addControl(stCtrl);//添加全景控件


//        http://api.map.baidu.com/library/MapWrapper/1.2/src/MapWrapper.min.js



//        var myMap = new BMap.Map("divMap");
//        myMap.centerAndZoom(new BMap.Point(116.404, 39.915), 12);

//        //可以转化gps坐标
//        var mapWforGPS = new BMapLib.MapWrapper(map, BMapLib.COORD_TYPE_GPS);
//
//        //可以转化google坐标
////        var mapWforGoogle = new BMapLib.MapWrapper(myMap, BMapLib.COORD_TYPE_GOOGLE);
//
//
//        for(var i = 0; i < 30; i++){
//
//            //添加gps坐标mkr
//            var gpsMkr = new BMap.Marker(new BMap.Point(/*GPS坐标*/116.397428, 39.75923 + i * 0.01));
//
////
//
//            mapWforGPS.addOverlay(gpsMkr);
//
//
//        }


    });

    var carno="";

    //    树节点选中
    var fnClick = function (event, treeId, treeNode) {
        var flag=treeNode.checked;
//        tree_Obj.checkAllNodes(false);
        tree_Obj.checkNode(treeNode, true, true);
//        cleanAll();
        debugger;
        selectTreeNode(treeNode,true);

    }

    //    复选框选中
    var fnCheck = function (event, treeId, treeNode, clickFlag) {
        var ids=selectTreeNode(treeNode,false);
        cleanAll();
        queryCarsByNo(ids,"1")
    }
    function selectTreeNode(treeNode,flag) {
        var isCar = treeNode.isCar
        var tChecked = treeNode.checked;
        var ids = setAllCarIds();
        if (isCar) {
            var baseCarNo=treeNode.name;
            if(tChecked){
                if(flag){
                    $("#h_c_car_baseCarNo").val(baseCarNo);
                    $("#h_c_car_id").val(treeNode.id);
                }
                carno=baseCarNo;
                queryCarsByNo(treeNode.id,"0",baseCarNo);
            }else{
                $("#h_c_car_id").val("");
            }

        }
        queryCars();
//        if (!tChecked) {
//            cleanAll()
//        }
        return ids;
    }
    function setAllCarIds() {
        var checkNodes = tree_Obj.getCheckedNodes(true);
        var ids = "";
        $.each(checkNodes, function (key, value) {
            var flag = value.isCar
            if (flag) {
                ids = ids + value.id + ","
                carno=value.name;
            }
        });
        $("#h_all_car_id").val(ids);
        return ids;
    }

    //刷新车辆列表
    function queryCars() {
        var allCarIds = $("#h_all_car_id").val();
        var jsonstr = [{"allCarIds": allCarIds}];
        gpsTable.DataTable().search(JSON.stringify(jsonstr), false, false).draw();
    }
    //刷新报警列表
    function querywarnings() {
//        var start = $("#start").val();
//        var end = $("#end").val();
//        var code = $("#serchStr").val();
        var jsonstr = [];
        warningTable.DataTable().search(JSON.stringify(jsonstr), false, false).draw();
        var info=warningTable.DataTable().rows().data();
        if(info && info.length>0){
//            play_sound();
        }
        var recordsTotal=info.recordsTotal;
    }
    //刷新车辆状态标题
    function querycartitle() {
        $.ajax({
            async: false,
            url: '/map/cartitle',
            type: "get",
            dataType: 'json',
            success: function (data) {
                if (data.success) {
                    var resData = data.data;
                    var warningtitle = "";

                    if (resData) {
                        warningtitle = "状态信息:操作日志(全部 " + resData.totalNum + ",在线：" + resData.onlineNum + ",离线：" + resData.offlineNum + ",行驶：" + resData.speedNum + ",停车：" +
                            resData.stopNum + ",在线率：" + resData.rate + ")"
                    } else {
                        warningtitle = "状态信息:操作日志(全部 " + 0 + "在线：" + 0 + " 离线：" + 0 + "行驶：" + 0 + " 停车：" + 0 + " 在线率：" + 100 % +")"

                    }
                    $("#warningRef").html(warningtitle);
                    $("#allcar").html("全部("+resData.totalNum+")");
                    $("#onlinecar").html("在线("+resData.onlineNum+")");
                    $("#offlinecar").html("离线("+resData.offlineNum+")");


                } else {
//                    swal({
//                        title: "系统提示",
//                        text: data.msg,
//                        type: "error"
//                    });
                }

            }
        })

    }
    //    ajax获取数据：根据车牌号获取实时数据，
    //    车牌号逗号分隔
//    ismanyIds=0dange  =1duoge

    function queryCarsByNo(carIds,ismanyIds,baseCarNo) {
        $.ajax({
            async: false,
            url: '/map/cars',
            type: "post",
            dataType: 'json',
            data: {
                carIds: carIds,
                ismanyIds:ismanyIds
            },
            success: function (data) {
                if (data) {
//                    var length1=carIds.split(",").length;
                    var resData = data.data;
                    debugger;
                    debugger;
                    var length=resData.length;
                    $.each(resData, function (key, value) {
                        var carObj = value;
                        //0绿色是跑的，1红色是异常的，2灰色是离线的,3蓝色是停止的，
                        var carError = 0;
                        var carstatus = "在线停止状态";
//                        点火， 熄火
                        var accstatus = "熄火";
                        var addressDetail = "无详细地址信息!";
                        //jwToAddress(carObj.jd,carObj.wd);
                        var myGeo = new BMap.Geocoder();
                        myGeo.getLocation(new BMap.Point(carObj.jd, carObj.wd), function (result) {
                            if (result) {
                                addressDetail = result.address;
                            }
                            if (carObj.onlineName == "0") {
                                carError = 2;
                                carstatus = "离线状态";
                            } else if (carObj.accFlag == "0") {
                                carError = 3;
                            } else if (carObj.accFlag == "1") {
                                carError = 0;
                                carstatus = "在线行驶状态"
                            }
//                            else if (carObj.onlineName == "1" && parseInt(carObj.speed) == 0) {
//                                carError = 3;
//                            } else if (carObj.onlineName == "1" && parseInt(carObj.speed) > 0) {
//                                carError = 0;
//                                carstatus = "在线行驶状态"
//                            }

                            if (carObj.accFlag == "1") {
                                accstatus = "点火";
                            }
                            var gpsPowerStatus = carObj.gpsPowerStatus;
                            var acc = carObj.accFlag;
                            var oneHigh = carObj.oneHigh;
                            var str=""
                            if(gpsPowerStatus == 1){
                                str="主电正常, "
                            }else{
                                str="主电异常, "
                            }
                            if (acc == 1) {
                                str = str+"点火, "
                            }else{
                                str = str+"熄火, "
                            }
                            if(oneHigh){
                                str=str+" 时长: "+oneHigh+"分钟"
                            }else{
                                str=str+" 时长: 0 分钟"
                            }
                            var content ='<div style="border:1px"><h4 style="margin:0 0 5px 0;padding:0.2em 0">实时信息</h4>' +
                                '<p style="margin:0;line-height:1.5;font-size:15px;text-indent:2em">' +
                                '车牌号：<span style="font-size:12px;">' +carObj.baseCarNo+ '</span>  </p>'
                                +'<p style="margin:0;line-height:1.5;font-size:15px;text-indent:2em">' +
                                '定位时间：<span style="font-size:12px;">' +carObj.gpsDate+ '</span> </p>'
                                +'<p style="margin:0;line-height:1.5;font-size:15px;text-indent:2em">' +
                                '终端号：<span style="font-size:12px;">' +carObj.terminal+ '</span> </p>'
                                +'<p style="margin:0;line-height:1.5;font-size:15px;text-indent:2em">' +
                                '当日里程：<span style="font-size:12px;">' +carObj.daydis+ '</span> </p>'
                                +'<p style="margin:0;line-height:1.5;font-size:15px;text-indent:2em">' +
                                '行驶速度：<span style="font-size:12px;">' +carObj.speed+ '</span> </p>'
                                +'<p style="margin:0;line-height:1.5;font-size:15px;text-indent:2em">' +
                                '状态：<span style="font-size:12px;">' +carstatus+ '</span> </p>'
                                +'<p style="margin:0;line-height:1.5;font-size:15px;text-indent:2em">' +
                                '当前位置：<span style="font-size:12px;">' +addressDetail+ '</span> </p>'  +
                                 '<div class="row">' +
                                '<div class="col-sm-3">' +
                                '   <button class="btn  btn-mini btn-primary btn-block m-t" onclick="editGps(0,'+carObj.id+')"><i class="fa fa-edit"></i>车辆</button>' +
                                '</div>' +
                                '<div class="col-sm-3">' +
                                '   <button class="btn btn-mini btn-primary btn-block m-t" onclick="openSj(\''+carObj.wd+'\',\''+carObj.jd+'\')"><i class="fa fa-map"></i>实景</button>' +
                                '</div>' +
                                '<div class="col-sm-3">' +
                                '   <button class="btn btn-mini btn-primary btn-block m-t" onclick="openhis('+carObj.id+',\''+carObj.baseCarNo+'\')"><i class="fa fa-map-marker"></i> 轨迹</button>' +
                                '</div>' +
                                '<div class="col-sm-3">' +
                                ' <button class="btn btn-primary btn-block m-t" onclick="openzz('+carObj.id+',\''+carObj.jd+'\',\''+carObj.wd+'\')"><i class="fa fa-arrow-down"></i> 追踪</button>' +
                                '</div>' +
                                '</div>' +
                                '</div>' +
                            "</div>";

//                            var content = '<div class="ibox float-e-margins" style="height:280px">' +
//                                '<div class="">' +
//                                '<h5>实时信息</h5>' +
//                                '</div>' +
//                                '<div class="ibox-content"  style="height:280px,OVERFLOW-Y: auto;"> ' +
////                            '<div class="ibox-content ">' +
//                                '车牌号：' + carObj.baseCarNo + '<br/>' +
//                                '定位时间：' + carObj.gpsDate + '<br/>' +
////                                '车辆类型:' + carObj.carType + '<br/>' +
////                                '所属用户:' + carObj.deptName + '<br/>' +
//                                '终端号:' + carObj.terminal + '<br/>' +
////                                'sim卡号:' + carObj.sim + '<br/>' +
//                                '当日里程:' + carObj.daydis + 'KM<br/>' +
////                                '当月里程:' + carObj.monthDis + 'KM<br/>' +
//                                '行驶速度:' + carObj.speed + '<br/>' +
//                                '状态:' + str + '<br/>' +
////                                '在线状态:' + carstatus + '<br/>' +
//                                '当前位置:' + addressDetail + '<br/>' +
//                                '<div class="row">' +
//                                '<div class="col-sm-3">' +
//                                '   <button class="btn btn-primary btn-block m-t" onclick="editGps(0,'+carObj.id+')"><i class="fa fa-edit"></i>车辆</button>' +
//                                '</div>' +
//                                '<div class="col-sm-3">' +
//                                '   <button class="btn btn-primary btn-block m-t" onclick="openSj('+carObj.wd+','+carObj.jd+')"><i class="fa fa-map"></i>实景</button>' +
//                                '</div>' +
//                                '<div class="col-sm-3">' +
//                                '   <button class="btn btn-primary btn-block m-t" onclick="openhis('+carObj.id+',\''+carObj.baseCarNo+'\')"><i class="fa fa-map-marker"></i> 轨迹</button>' +
//                                '</div>' +
//                                '<div class="col-sm-3">' +
//                                ' <button class="btn btn-primary btn-block m-t" onclick="openzz('+carObj.id+','+carObj.jd+','+carObj.wd+')"><i class="fa fa-arrow-down"></i> 追踪</button>' +
//                                '</div>' +
//                                '</div>' +
//                                '</div>' +
//                                '</div>';
//                            '</div>';
                            var panTo=false
                            baseCarNo=$("#h_c_car_baseCarNo").val();
                            if(baseCarNo && baseCarNo==carObj.baseCarNo){
                                panTo=true;
                            }
//                            else
//                                if(key === length - 1){
//                                panTo=true
//                            }
//                            if(!baseCarNo){
//                                panTo=false;
//                            }
//                                alert(panTo);
//                                if(length1>1){
//                                    panTo=false;
//                                }
                            addMarker(carObj.wd, carObj.jd, carObj.baseCarNo, carObj.driection, carError, content,panTo);


                        });


                    });

                } else {
//                    swal({
//                        title: "系统提示",
//                        text: data.msg,
//                        type: "error"
//                    });
                }

            }
        })
    }
    //    刷新数据
    var refData = function refCarsById() {
        cleanAll();
        var carId = $("#h_c_car_id").val();
        var carIds=$("#h_all_car_id").val();
        if(carIds){
            queryCarsByNo(carIds,"1",carno);

        }else{
            queryCarsByNo(carId,"0",carno);

        }
        queryCars();
//        querywarnings();
//        querycartitle();
//        loadMyTree(urlTree);
    }
    //    刷新数据
    var refData1 = function refCarsById() {
//        cleanAll();
//        var carId = $("#h_c_car_id").val();
//        var carIds=$("#h_all_car_id").val();
//        if(carIds){
//            queryCarsByNo(carIds,"1",carno);
//
//        }else{
//            queryCarsByNo(carId,"0",carno);
//
//        }
//        queryCars();
        querywarnings();
        querycartitle();
//        loadMyTree(urlTree);
    }


    /**
     * 清除标注
     */
    function clean() {
        map.clearOverlays();
    }

    function openhis(id,carNo) {
        window.open("/map/his?carId="+id+"&carNo="+carNo);
    }
    function openzz(carid,jd,wd) {
        window.open("/map/carmap?carId="+carid+"&jd="+jd+"&wd="+wd);
    }
    var traffic=new BMap.PanoramaCoverageLayer()
    function openSj(wd,jd) {
        debugger;
        map.addTileLayer(traffic);
        panorama.show();
        panorama.setPosition(new BMap.Point(jd, wd));
//        panorama.setOptions({
//            navigationControl: false //显示导航控件
//        });
    }
    function editGps(index,id) {
            $.ajax({
                type: "GET",
                url: "/baseCar/edit",
                cache: false,
                async: false,
                data:{
                   id: id
                },
                dataType: "json",
                success: function (data) {
                    $('#editForm').loadDate(data);
                    $("#myModal").modal("show");
                }
            });

    }
    function closeModal() {
        $("#myModal").modal("hide");
    }
</script>
<script>
    $(function () {

        parent.menuclick();
    });


    function testupdate() {
        var carNo=$("#serchStr").val();
        var online=0;
        var speed=0;
        var warningType=5;
        updateTreeCarState(carNo,online,speed,warningType);
    }
    //根据返回数据，查询查询出该节点并查看是否被check，check的更新数据；
    function updateTreeCarState(carNo,online,speed,warningType) {
        var nodeList = tree_Obj.getNodesByParamFuzzy("name", carNo);
        if(nodeList && nodeList.length>0){
            for( var i=0; i<nodeList.length;  i++) {
                var node=nodeList[i];
                var tChecked = node.checked;
                if(tChecked){
                    updateTreeNodeBySoket(nodeList[i],online,speed,warningType);

                }
            }

        }
    }
</script>
<div id="div1"></div>
</body>

</html>
